<?php
$mysql = new SaeMysql();

$ali_url = "http://www.bjstbjgs.com";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $ali_url);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$file = curl_exec($ch);
$file =  mb_convert_encoding($file, "UTF-8", "GBK");
$key_word_pattern = "/name=\"keywords\"\s+content=\"(.*)\"/u";
preg_match_all($key_word_pattern, $file, $matches);
$key_word = mysql_real_escape_string($matches[1][0]);
echo $key_word;
$company_pattern = "/[\x{4e00}-\x{9fa5}]+(集团|公司)/u";
preg_match_all($company_pattern,$file,$matches);
$company_name = mysql_real_escape_string($matches[0]);
$pattern = "/1(3|5)\d{9}/";
preg_match_all($pattern, $file, $matches);
$mobile_num = $matches[0];
$pattern = "/0\d+-\d{7-8}/";
preg_match_all($pattern, $file, $matches);
$tel_num = $matches[0];

foreach ($company_name as $company){}
if ((strlen($mobile_num[0])>10)||(strlen($tel_num)>8)) {
	//echo $company;
	//echo $mobile_num[0];
	//echo $tel_num[0];
	//echo $key_word;
	$sql = "INSERT  INTO `customer` ( `complany_name` , `mobile_num`,'tel_num','key_words' ,'search_word') VALUES ('$company' , '$mobile_num[0]','$tel_num[0]','$key_word','婚纱' ) ";
	echo $sql;
	$mysql->runSql( $sql );
	if( $mysql->errno() != 0 )
	{
		die( "Error:" . $mysql->errmsg() );
	}
}
curl_close($ch);


$mysql->closeDb();
?>